package com.fuzhenguo.boltmusic;

import java.util.ArrayList;
import java.util.UUID;

import android.provider.MediaStore.Audio.Albums;
import android.provider.MediaStore.Audio.Media;
import android.provider.MediaStore.MediaColumns;
import android.util.Log;

public class Category {

    private static final String TAG = "Category";
    ArrayList<Album> mAlbumList;
    UUID mId;
    String mName;
    int mSize;

    public Category() {
        mAlbumList = new ArrayList<Album>();
        mId = UUID.randomUUID();
        mSize = 0;
        mName = "";
    }

    public Category(ArrayList<Album> albumList, String name) {
        if (albumList != null) {
            mAlbumList = albumList;
        } else {
            Log.w(TAG,
                    "Use null as parameter albumlist of Category's constructor.");
            mAlbumList = new ArrayList<Album>();
        }
        
        if (name != null) {
            mName = name;
        } else {
            mName = "";
        }
        
        mId = UUID.randomUUID();
        mSize = mAlbumList.size();
    }

    public String getmName() {
        return mName;
    }

    public void setmName(String name) {
        this.mName = name;
    }

    public ArrayList<Album> getmAlbumList() {
        return mAlbumList;
    }

    public UUID getmId() {
        return mId;
    }

    public int getmSize() {
        return mSize;
    }

    public boolean addAlbum(Album album) {
        if (mAlbumList.contains(album)) {
            return true;
        } else {
            if (album.isValid()) {
                mAlbumList.add(album);
                return true;
            } else {
                return false;
            }
        }
    }

    public boolean removeAlbum(Album album) {
        if (mAlbumList.contains(album)) {
            if(mAlbumList.remove(album)) {
                return true;
            } else {
                return true;
            }
        } else {
            return false;
        }
    }
}
